Repository navigation
fix(id): tie serve-lock liveness to the process incarnation (#3040) - #8667
Conversation
The serve lock recorded only a PID and get_serve_info tested PID existence, so a PID reused by an unrelated process made a dead serve look alive and wedged discovery on its endpoint. ServeInfo now also records the serve process start time (Linux /proc/<pid>/stat field 22) at lock creation; is_process_alive compares it when both sides have one and reports stale on mismatch. Locks written before this field, and platforms without a readable start time, fall back to the existing existence probe (kill(pid,0), EPERM counts as alive, sentinel PIDs refused) unchanged. Ports draft PR #4090 onto current main. Tests: cargo test test_is_process_alive — 6/6, including a new reused-PID regression (off-by-one start time reads stale).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce1874b8ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let actual = get_process_start_time(pid).expect("own start time is readable"); | ||
| assert!(is_process_alive(pid, Some(actual))); | ||
| assert!(!is_process_alive(pid, Some(actual + 1))); |
There was a problem hiding this comment.
Add property coverage with an independent start-time oracle
The regression obtains actual through the same parser used by is_process_alive, so accidentally extracting another numeric /proc/<pid>/stat field would still pass both assertions. The new parser has a meaningful invariant—extracting field 22 regardless of spaces or parentheses in comm—but only receives this self-referential example coverage. Extract the string parsing into a helper and add property tests using generated process names and an independently selected field-22 value, as required by the repository’s testing doctrine.
AGENTS.md reference: AGENTS.md:L42-L46
Useful? React with 👍 / 👎.
|
agent-note:v1
|
Summary
Fixes #3040: the serve lock recorded only a PID and
get_serve_info()tested PID existence, so a PID reused by an unrelated process made a dead serve look alive and wedged discovery on its endpoint.ServeInfonow also records the serve process start time (Linux/proc/<pid>/statfield 22, clock ticks since boot) at lock creation;is_process_alivecompares it when both sides have one and reports stale on mismatch. Locks written before this field, and platforms without a readable start time, fall back to the existing existence probe (kill(pid, 0), EPERM counts as alive, sentinel PIDs refused) unchanged.This cherry-picks commit
2c6ff3ec85from branchqueue/5649-3040-serve-lock(a port of draft PR #4090 onto main, prepared earlier today) onto current main — PR #4090 itself was closed unmerged on 2026-11-11, which cleared this task's recorded hard-stop gate.Tests
cargo test --lib -- test_is_process_alive test_serve_infoon this branch: all pass, including the newtest_is_process_alive_reused_pidregression (a live PID with an off-by-one recorded start time reads stale) and the pre-existing sentinel/dead-PID cases and ServeInfo JSON roundtrips (old locks without the field still parse via#[serde(default)]).Fleet task 5649 (lane any-a). The task's lane row was bound to a cleared legacy opencode session (ses_e5e37c9779...; cleared 2026-11-11T01:33Z, flip refused); pickup state and the gate change are recorded on #3040.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.